import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
import 'dart:convert';
class DioDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new DioDemoState();
  }
}

class DioDemoState extends State<DioDemo> {
  var data = '11';

  getData() async {
    if(data.length > 2){
      return ;
    }
    Dio dio = new Dio();
    Response response;
    response=await dio.get("https://dsn.apizza.net/mock/d9ece8d859722233416fa78ba498d717/user");
    print(response.data);

    setState(() {
      data = response.toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    getData();
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Page 3'),
      ),
      body: new Container(
        child: new Text(data),
      ),
    ) ;
  }

}